package com.fanw.easyExport.core;

import com.fanw.easyExport.core.config.ExportConfig;
import com.fanw.easyExport.core.data.DataFetcher;
import com.fanw.easyExport.core.file.FileGenerator;
import com.fanw.easyExport.core.model.ExportResult;

import java.util.List;
import java.util.Map;

/**
 * EasyExport 核心类
 */
public class EasyExport {
    private final ExportConfig config;
    private final DataFetcher dataFetcher;

    public EasyExport(ExportConfig config, DataFetcher dataFetcher) {
        this.config = config;
        this.dataFetcher = dataFetcher;
    }

    public ExportResult execute() {
        // 1. 获取数据
        List<Map<String, Object>> data = dataFetcher.fetchData();

        // 2. 生成文件
        FileGenerator fileGenerator = new FileGenerator();
        return fileGenerator.generateFile(config, data);
    }
}
